package com.cry.todo.domain.audit;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;

import org.hibernate.envers.RevisionEntity;
import org.hibernate.envers.RevisionNumber;
import org.hibernate.envers.RevisionTimestamp;

import com.cry.todo.domain.User;

@Entity
@RevisionEntity(AuditRevisionListener.class)
public class AuditRevisionEntity {
	@Id
	@GeneratedValue
	@RevisionNumber
	private Integer id;
	@RevisionTimestamp
	private Long timestamp;

	@ManyToOne(fetch=FetchType.EAGER)
	private User modifiedBy;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Transient
	public Date getDateTime() {
		return new Date(timestamp);
	}
	
	public Long getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(Long timestamp) {
		this.timestamp = timestamp;
	}

	public User getModifiedBy() {
		return modifiedBy;
	}

	public void setModifiedBy(User modifiedBy) {
		this.modifiedBy = modifiedBy;
	}
}
